/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.service.organization;
import com.alibaba.fastjson.JSONObject;
import com.qinyetech.springstage.core.lang.QyMap;
import com.qinyetech.springstage.core.service.IBaseService;
import com.qinyeit.serviceapp.entity.Branch;

import javax.validation.Valid;
import java.util.List;

/** 
 * ClassName: BranchService <br/> 
 * Function: 分店业务功能 <br/> 
 * date: 2018-11-21 15:03:05 <br/> 
 * 
 * @author liuwenjin
 * @version 1.0
 * @since JDK 1.8
 */
public interface BranchService extends IBaseService<Branch, Long>{

    /**
     * 更新单店版
     * @param branch
     */
    Branch updateBranch(Branch branch,String password);

    /**
     * 关联门店  验证门店用户名和密码
     * @param branch
     */
    QyMap verify(Branch branch);

    /**
     * 关联门店保存数据
     * @param data
     *    branch:分店信息
     *    merchant:单店版分店信息(第一部验证的数据）
     *    code:验证码
     *    phone:电话
     *
     */
    void saveRelevance(JSONObject data,Long merchantGroupId,String operatorName);

    /**
     * 验证短信验证码
     * @param phone
     * @param code
     */
    void verifySmsCode(String phone,String code);

    /**
     * 解绑门店验证
     * @param data
     *    name:ccc
     *    username:xxx
     *    password:123
     */
    QyMap unRelevanceValidate(JSONObject data,Long merchantGroupId);

    /**
     * 解绑门店
     * @param data
     *      merchantGroupId:
     *      username
     *      merchantId
     *      name
     */
    void unRelevance(JSONObject data,Long merchantGroupId);

    /**
     * 根据区域获取门店列表
     * @param districtId 区域id
     * @param flag 是否是门店级联
     * @return
     */
    List<Branch> getBranchByDistrictId(Long districtId,List<Long> branchIds,Boolean flag);

    /**
     * 保存连锁店的权限
     * @param branch
     */
    void updateBranchPermissions(Branch branch);

    /**
     * 根据门店id 获取 商户id
     * @param branchId
     * @return
     */
    Long getMerchantIdByBranchId(Long branchId);
    /**
     * 根据商户id 获取门店信息
     * @param merchantId
     * @param merchantGroupId
     * @return
     */
    Branch getBranchByMerchantId(Long merchantId,Long merchantGroupId);


    /**
     * 修改单店对应数据
     * @param branch
     */
    void updateBranchData(@Valid Branch branch);
}